package com.ican.oc.dao;

import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ican.oc.common.hibernate.OcSimpleDao;

@Repository("ocDataSynDao")
public class OcDataSynDao extends OcSimpleDao{
    
    //汇率
    @SuppressWarnings("rawtypes")
    public Double getPriceRate(String unit){
        if(unit == null || unit.trim().length() < 1){
            return null;
        }
        unit = unit.trim();
        String sql = "select distinct `value` from `currency` where `code` = '" + unit + 
        		"' OR symbol_left = '" + unit + "' OR symbol_right = '" + unit + "'";
        Map map = this.queryUnique(sql);
        if(map != null){
            return Double.valueOf(map.get("value").toString());
        }
        return null;
    }
    //重量单位
    @SuppressWarnings("rawtypes")
    public Integer getWeightUnitId(String unit){
        if(unit == null || unit.trim().length() < 1){
            return null;
        }
        unit = unit.trim();
        String sql = "select distinct weight_class_id from `weight_class_description` where `unit` = '" + unit + "'";
        Map map = this.queryUnique(sql);
        if(map != null){
            return (Integer) map.get("weight_class_id");
        }
        return null;
    }	
}